package com.home.timesheet.service;

import java.util.List;

import com.home.common.BaseService;
import com.home.timesheet.dao.TimesheetDao;
import com.home.timesheet.entity.TimesheetVO;
import com.home.timesheet.entity.TimesheetVOImpl;

public class TimesheetServiceImpl extends BaseService implements TimesheetService  {
    private TimesheetDao timesheetDao;


    public void setTimesheetDao(TimesheetDao timesheetDao) {
        this.timesheetDao = timesheetDao;
    }

    public List<TimesheetVOImpl>  findAllByUserId(String userId) {
        return timesheetDao.findAllByUserId(userId);
    }

    public int save(TimesheetVO timesheet) {
        return 0;
    }

    public int update(TimesheetVO timesheet) {
        return 0;
    }

    /**
     * 保存多个对象
     * @param tsList
     * @return
     */
    public int saveList(List<TimesheetVOImpl> tsList){
        timesheetDao.saveList(tsList);
        for(int i=0,k=tsList.size();i<k;i++){
            System.out.println("tsList.get(i).getTimesheetId():"+tsList.get(i).getTimesheetId()+":"+tsList.get(i).getForeCast());
            if(tsList.get(i).getTimesheetId() == null){
               super.getLog(getClass()).error("Be faild to save List<TimesheetVOImpl> ");
               return 1;
            }
        }
        return 0;
    }
}
